#pragma strict
@script AddComponentMenu("Level4/Misc/AlwaysFaceCamera")
//////////////////////////////////////////////////////
///一直面向摄影机.(y轴跟随摄影机转动)
//////////////////////////////////////////////////////
var camTransform:Transform;
private var curTransform:Transform;

function Start(){
	if(!camTransform){
		var go:GameObject = GameObject.FindWithTag("MainCamera");
		if(go)
			camTransform = go.transform;
	}
	curTransform = transform;
}

function Update() {
	if(curTransform && camTransform){
		// curTransform.eulerAngles.y = cam.transform.eulerAngles.y;
		curTransform.rotation = camTransform.rotation;
	}else{
		Debug.LogWarning("摄影机未找到,禁用AlwaysFaceCamera");
		enabled = false;
	}
}